GBML manual / Camera

camera_x

Where the camera’s view begins, across: the x of the left edge of what the screen shows, counted from the room’s top-left corner.

Syntax

camera_x() -> real

Returns

real

Description

The camera's current horizontal position. Useful for anything that needs to reason about what is actually on screen right now - whether a far-off instance is worth updating in detail, or a parallax layer that should track the camera at a fraction of its speed.

It gives the x where the view begins - the left edge of what the screen shows - counted from the room's top-left corner. A thing at world x appears on the screen at x - camera_x().

Example

var cx = camera_x();

Reads where the view begins, across, into a local variable.

See also: camera_y